const state = {
  count: 10
}
const mutations = {
  updateCount(state, paylod) {
    state.count = state.count + paylod
  }
}
const actions = {
  updateCount(context, paylod) {
    setTimeout(() => {
      context.commit('updateCount', paylod)
    }, 2000)
  }
}
const getters = {
  points: state => state.user.userInfo && state.user.userInfo.roles.point,
  routes: state => state.permission.list,
  sidebar: state => state.app.sidebar,
  device: state => state.app.device,
  token: state => state.user.token,
  avatar: state => state.user.userInfo && state.user.userInfo.staffPhoto,
  name: state => state.user.name,
  username: state => state.user.userInfo && state.user.userInfo.username, // 这个是短路运算,并且是短路与的运算，短路的特点就是如果短路了得到的值是造成短路的值，如果不短路得到的值就是第二个值
  // getter可以基于state中已有的数据生成另一种数据
  // specialCount: state => state.count + 100
  // 如果数据两边需要尖括号
  specialCount: state => '<' + (state.count + 100) + '>'
}
export default {
  // 全局配置
  state,
  mutations,
  actions,
  getters
}
